<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- <script type="text/javascript" src="../../Public_Html/Header/Header.js"></script> -->
    <!-- <script type="text/javascript" src="../../Public_Html/Search/Search.js"></script> -->
    <!-- <link ref="stylesheet" href="../index/index.css"> -->
    <link rel="stylesheet" href="../../css/Untils/public.css">
    <link rel="stylesheet" href="screen.css">
    <title>筛选页</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .margin-top {
            margin-top: 10px;
        }

        .margin-top2 {
            margin-top: 16px;
        }

        .margin-left {
            margin-left: 10%;
        }

        .margin-left2 {
            margin-left: 50px;
        }

        .margin-left1 {
            margin-left: 20px;
        }

        .margin-left_logo {
            margin-left: 10%;
        }

        .margin-left_select {
            margin-left: 7px;
        }

        /*导航*/
        header {
            background-color: #2dbb55;
            color: white;
            margin: 0 auto;
            vertical-align: middle;
            min-width: 1400px;
        }

        header a {
            margin-right: 10px;
        }


        /*先找到header，再找到logo*/
        header a .logo {
            width: 140px;
            height: 40px;
            line-height: 40px;
            text-align: center;
            margin-top: 4px;
        }


        /*导航字体*/
        .header_font {
            font-size: 16px;
            font-family: initial;
        }

        /*后代选择器*/
        #navitems ul {
            /* 去除小黑点 */
            list-style: none;
            display: flex;
        }

        #navitems ul li {
            width: 80px;
            height: 44px;
            line-height: 50px;
            text-align: center;
        }

        #navitems ul li a {
            display: block;
            /*区块化*/
            color: white;
            text-decoration: none;
        }

        #navitems ul li:nth-child(2):after {
            display: block;
            width: 16px;
            height: 16px;
            content: "hot";
            color: white;
            background-color: red;
            position: relative;
            left: 50px;
            top: -46px;
            font-size: 10px;
            line-height: 16px;
            text-align: center;
            border-radius: 5px;
        }

        #navitems ul li:nth-last-child(4):after {
            display: block;
            width: 16px;
            height: 16px;
            content: "hot";
            color: white;
            background-color: red;
            position: relative;
            left: 46px;
            top: -46px;
            font-size: 10px;
            line-height: 16px;
            text-align: center;
            border-radius: 5px;
        }

        #navitems ul li a:hover {
            font-weight: bold;
            background-color: rgb(80, 251, 137);
            color: white;
            box-shadow: 0 2px 3px 0 rgba(0, 0, 0, .05);
        }

        /*第一个子元素*/
        #navitems ul li:first-child {
            /* background-color: aquamarine; */
        }

        /*最后一个子元素*/
        #navitems ul li:last-child {
            /* background-color: rgb(71, 223, 94); */
        }

        /*第n个子元素*/
        #navitems ul li:nth-child(2) {
            /*从1开始*/
            /* background-color: rgb(160, 115, 237); */
        }

        /*倒数第n个元素*/
        #navitems ul li:nth-last-child(2) {
            /*倒数第2个*/
            /* background-color: bisque; */
        }

        /*直接第一层子元素*/
        .par>span {
            /* color: darkorange; */
        }

        /*下一个兄弟元素*/
        .s1 span+label+label {
            /* font-size: 30px; */
        }

        /*属性选择器*/
        input[type="password"] {
            /* color: green; */
        }

        /*伪类*/
        a {
            color: black;
            text-decoration: none;
        }

        a:hover {
            /*鼠标悬浮*/
            font-weight: bold;
            /*加粗*/
            text-decoration: none;
            color: #000;
        }

        /*被点击后的样式*/
        a:visited {
            /* color: yellow; */
        }

        /*伪元素*/
        .hot_pro {
            display: block;
            width: 60px;
            height: 40px;
            text-decoration: none;
            line-height: 40px;
            text-align: center;
            font-size: 14px;
            color: white;
            background-color: rgb(235, 177, 97);
            box-shadow: 0 2px 3px 0 rgba(0, 0, 0, .05);
        }

        .hot_pro::after {
            display: block;
            content: "hot";
            width: 16px;
            height: 16px;
            color: white;
            background-color: red;
            position: relative;
            /*相对定位*/
            left: 48px;
            top: -48px;
            font-size: 10px;
            line-height: 16px;
            text-align: center;
            border-radius: 5px;
        }
    </style>
</head>

<body>
    <div id="app">
        <header class="flex header_font" style="width: 100%;">
            <div class="margin-left_logo">
                <a href="" style=" margin-right: 40px;">
                    <img src="//img3.tuniucdn.com/u/mainpic/logo/logo_20170124.png" title="途牛网" class="logo">
                </a>
            </div>

            <!--菜单模块-->
            <div id="navitems">
                <ul id="navitems_groups">
                    <li><a href="javascript:void(0)" @click="skipToIndex">首页</a></li>
                    <li><a href="javascript:void(0)">跟团游</a></li>
                    <li><a href="javascript:void(0)">自行游</a></li>
                    <li><a href="javascript:void(0)">酒+景</a></li>
                    <li><a href="javascript:void(0)">酒店</a></li>
                    <li><a href="javascript:void(0)">门票</a></li>
                    <li><a href="javascript:void(0)">定制游</a></li>
                    <li><a href="javascript:void(0)">攻略</a></li>
                    <li><a href="javascript:void(0)" @click="skipToCustomerServer">客服</a></li>
                    <li><a href="javascript:void(0)" @click="skipToCustomer">个人中心</a></li>
                </ul>
            </div>

            <!--登录注册-->
            <div class="flex">
                <div class="flex" v-if="isLogin" style="margin-top: 12px;">
                    <i class="el-icon-user-solid" style="margin-top: 2px;"></i>
                    <div>{{admin.userNickName}}</div>
                    <div style="margin-left: 20px;" @click="signOut">
                        <a href="javascript:void(0)" style="color: white;">退出登录</a>
                    </div>
                </div>
                <div v-if="!isLogin" class="flex" style="margin-top: 12px;">
                    <div class="margin-left" style="width: 60px;">
                        <a href="../../html/admin/admin.html" class="header_font" style="color: white;">
                            登录
                        </a>
                    </div>
                    <div class="margin-left" style="width: 60px;">
                        <a href="../../html/register/register.html" style="color: white;">
                            注册
                        </a>
                    </div>
                </div>
            </div>
        </header>

        <div class="flex_wrap" id="body">

            <!--筛选区域-->
            <div class="screen ">
                <div class="flex_wrap">

                    <!--搜索区域-->
                    <div style="margin-bottom: 40px;margin-left:60px;">
                        <!--搜索框1-->
                        <div class="search_key1">
                            <div class="center padding-body search_float">
                                <div class="flex">
                                    <div class="serach_body flex">
                                        <div class="search_div1 flex" @click="closeCity">
                                            <div
                                                style="width: 15px;height:18px;margin-left: 20px;margin-top: 4px;margin-right: -16px;">
                                                <img src="../../img/logo/address.png" style="width: 15px;height:18px">
                                            </div>
                                            <input type="text" class="search" placeholder="请选择城市" v-model="city">
                                            <div v-if="isShowForm" class="selectCity" style="top: 150px;">
                                                <div class="single"></div>
                                                <div class="flex_wrap">
                                                    <div class="flex">
                                                        江苏省
                                                    </div>

                                                    <div class="city flex flex_around">
                                                        <div v-for="(item,i) in cityArr" id="city_arr">
                                                            <div class="flex_wrap">
                                                                <!--城市-->
                                                                <div id="city_arr">
                                                                    <ul>
                                                                        <li>
                                                                            <a href="javascript:void(0)"
                                                                                @click="selectCity($event)">{{item.cityName}}</a>
                                                                        </li>
                                                                    </ul>
                                                                </div>

                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="search_div2 flex">
                                            <div class="block">
                                                <el-date-picker
                                                    style="border-top: none;border-bottom: none;border-radius: 0;margin-bottom: 2px;"
                                                    v-model="date" type="daterange" range-separator="至"
                                                    start-placeholder="入住日期" end-placeholder="退房日期">
                                                </el-date-picker>
                                            </div>
                                        </div>

                                        <div class="search_div1 flex">
                                            <div
                                                style="width: 18px;height:16px;margin-left: 20px;margin-top: 4px;margin-right: -16px;">
                                                <img src="../../img/logo/search.png" style="width: 18px;height:16px">
                                            </div>
                                            <input type="text" class="search" placeholder="关键字搜索" v-model="txtStr">
                                        </div>
                                    </div>
                                    <div class="" @click="searchBtn">
                                        <div class="searchBtn" role="button"><i class="el-icon-search"></i>搜索酒店</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!--筛选区域-->
                    <div>
                        <!--改成变量 没选择一样展示对应的东西-->
                        <el-breadcrumb separator="/">
                            <el-breadcrumb-item>筛选</el-breadcrumb-item>
                            <el-breadcrumb-item><a href="javascript:void(0)">{{screenProvince}}</a></el-breadcrumb-item>
                            <el-breadcrumb-item>{{screenCity}}</el-breadcrumb-item>
                            <el-breadcrumb-item>{{screenArr}}</el-breadcrumb-item>
                            <el-breadcrumb-item>{{screenBusiness}}</el-breadcrumb-item>
                        </el-breadcrumb>
                    </div>
                    <!--省份-->
                    <div class="flex">
                        <div class="margin_top1">省份：</div>
                        <div class="margin_top0">
                            <div>
                                <el-checkbox-group v-model="screenProvince" size="small">
                                    <el-checkbox-button v-for="item in provinceArr" :label="item"
                                        :disabled="item.provinceName != '江苏省'" :key="item.provinceId">
                                        {{item.provinceName}}</el-checkbox-button>
                                </el-checkbox-group>
                            </div>
                        </div>
                    </div>
                    <!--城市-->
                    <div class="flex">
                        <div class="margin_top1">
                            城市：
                        </div>
                        <div class="margin_top0">
                            <div>
                                <el-checkbox-group v-model="screenCity" size="small">
                                    <el-checkbox-button v-for="item in cityArr" :label="item"
                                        :disabled="item.cityName != '苏州'" :key="item.cityId">{{item.cityName}}
                                    </el-checkbox-button>
                                </el-checkbox-group>
                            </div>
                        </div>
                    </div>
                    <!--区域-->
                    <div class="flex">
                        <div class="margin_top1">
                            区域：
                        </div>
                        <div class="margin_top0">
                            <div>
                                <el-checkbox-group v-model="screenArr" size="small">
                                    <el-checkbox-button v-for="area in areaArr" :label="area" :key="area">
                                        {{area.areaName}}
                                    </el-checkbox-button>
                                </el-checkbox-group>
                            </div>
                        </div>
                    </div>
                    <!--商圈-->
                    <div class="flex">
                        <div class="margin_top1">
                            商圈：
                        </div>
                        <div class="margin_top0">
                            <div>
                                <el-checkbox-group v-model="screenBusiness" size="small">
                                    <el-checkbox-button v-for="place in placeArr" :label="place" :key="place.placeId">
                                        {{place.placeName}}</el-checkbox-button>
                                </el-checkbox-group>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!--列表-->
            <div class="flex_wrap" id="list">
                <!--列表头部-->
                <div class="flex flex_between" id="list-head">
                    <div class="font_weight">
                        为您找到了{{hotelArr.length}}家酒店
                    </div>
                    <div class="flex">
                        <div>
                            <a href="javascript:void(0)" class="font_li" @click="priceDescBtn">价格高-低</a>
                        </div>
                        <div class="margin_sort">
                            <a href="javascript:void(0)" class="font_li" @click="priceAscBtn">价格低-高</a>
                        </div>
                        <div class="margin_sort">
                            <a href="javascript:void(0)" class="font_li" @click="remarkDescBtn">评价高-低</a>
                        </div>
                    </div>
                </div>
                <!--列表整体-->
                <div id="list-body">
                    <div id="list-body-list">
                        <ul>
                            <li v-for="(item,i) in esList">
                                <!--每页展示10条记录-->
                                <!---->
                                <div class="flex flex_between">
                                    <div class="img_style">
                                        <img :src="item.hotelShowImg" class="img" />
                                    </div>
                                    <div class="flex_wrap hotel_detail">
                                        <div class="flex">
                                            <div class="hotelName">{{item.hotelName}}</div>
                                            <div class="flex img_logo_style">
                                                <div v-for="n in item.starRanting">
                                                    <img src="../../img/logo/diamond.png" class="img_logo">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="flex margin_top2">
                                            <div
                                                :class="[item.hotelMark == 5? 'hotelMark color2': (item.hotelMark < 4 ? 'hotelMark color3':'hotelMark color1')]">
                                                {{item.hotelMark}}</div>
                                            <div
                                                :class="[item.hotelMark == 5? 'hotelMark_status font_col2': (item.hotelMark < 4 ? 'hotelMark_status font_col3':'hotelMark_status font_col1')]">
                                                {{item.hotelMark<4?"一般！":"超棒！"}}
                                                <!-- <div class="comment">{{item.hotelAssess}}条评论</div> -->
                                            </div>
                                            <div class="comment">
                                                距市中心直线{{item.hotelDistance}}公里
                                            </div>
                                        </div>
                                    </div>
                                    <!--价格-->
                                    <div class="flex_wrap" style="margin-left: 230px;margin-right: 0;">
                                        <div class="flex">
                                            <div class="price_logo font_col2">￥</div>
                                            <div class="price font_col2">{{item.roomLeastPrice}}</div>
                                            <div class="price_font">起</div>
                                        </div>
                                        <div class="active">
                                            限时促
                                        </div>
                                        <button class="checkDetail" :key="i" @click="checkDetail(i)">
                                            查看详情
                                        </button>
                                    </div>
                            </li>
                        </ul>
                        <div class="page" style="margin-left: 350px;">
                            <!-- 分页 -->
                            <!-- <el-pagination background layout="prev, pager, next" :total="1000">
                            </el-pagination> -->
                            <div class="block">
                                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                    :current-page="currentPage4" :page-sizes="[8]" :page-size="8"
                                    layout="total, sizes, prev, pager, next, jumper" :total=hotelTotal>
                                </el-pagination>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--引用vue-->
    <script src="../../js/untils/vue.js"></script>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!-- 引入组件库 -->
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <script src="../../js/untils/axios-0.18.0.js"></script>
    <!--vue-->
    <script>
        new Vue({
            el: "#app",
            // 数据
            data() {
                return {
                    admin: {}, //用户登录信息
                    isLogin: false,
                    esPage: 0,
                    // 搜索框
                    city: '', // 搜索框选择的城市
                    isShowForm: false, // 是否展示城市选择框
                    isShowFormXF: false, // 悬浮框的城市选择框
                    esList: [], //es查询出的所有内容
                    screenProvince: '江苏省', // 省份
                    screenCity: '苏州市', // 城市
                    screenArr: '吴中区', // 区域
                    screenBusiness: '金鸡湖', // 商圈
                    date: '', // 日期
                    currentPage: 1, // 当前页
                    pageSize: 8, // 每页展示
                    hotelTotal: 0, // 总记录数
                    currentPage4: 0,
                    // 接收过来的酒店数据
                    hotelArr: [],
                    txtStr: "", //存储首页搜索框内容

                    img: 'https://m.tuniucdn.com/fb2/t1/G6/M00/1B/6F/Cii-U13MI7yIaaIBAASXRtYyADUAADDHADfQtUABJde465_w200_h200_c1_t0_w360_h200_c1_t0.jpg',
                    // 搜索框城市数组
                    cityArr: [{
                            cityid: 1,
                            cityName: "南京",
                        },
                        {
                            cityid: 2,
                            cityName: "苏州",
                        },
                        {
                            cityid: 3,
                            cityName: "无锡",
                        },
                        {
                            cityid: 4,
                            cityName: "南通",
                        },
                        {
                            cityid: 5,
                            cityName: "常州",
                        },
                        {
                            cityid: 6,
                            cityName: "泰州",
                        },
                        {
                            cityid: 7,
                            cityName: "扬州",
                        },
                        {
                            cityid: 8,
                            cityName: "徐州",
                        },
                        {
                            cityid: 9,
                            cityName: "盐城",
                        },
                        {
                            cityid: 10,
                            cityName: "镇江",
                        },
                        {
                            cityid: 11,
                            cityName: "淮安",
                        },
                        {
                            cityid: 12,
                            cityName: "连云港",
                        },
                        {
                            cityid: 13,
                            cityName: "宿迁",
                        }
                    ],
                    date: '', // 日期

                    currentPage4: 1,
                    currentPage: 1, // 当前页
                    pageSize: 8, // 每页展示
                    hotelTotal: 0, // 总记录数

                    // 接收过来的酒店数据
                    hotelArr: [],

                    // 省份
                    provinceArr: [{
                            provinceId: 001,
                            provinceName: '上海',
                        },
                        {
                            provinceId: 002,
                            provinceName: '北京',
                        },

                        {
                            provinceId: 003,
                            provinceName: '江苏省',
                        },

                        {
                            provinceId: 004,
                            provinceName: '广东省',
                        },
                        {
                            provinceId: 005,
                            provinceName: '浙江省',
                        }
                    ],
                    // 城市
                    cityArr: [{
                            cityId: 1,
                            cityName: '苏州',
                            cityReside: 001
                        },
                        {
                            cityId: 2,
                            cityName: '南京',
                            cityReside: 001
                        },
                        {
                            cityId: 3,
                            cityName: '无锡',
                            cityReside: 001
                        },
                        {
                            cityId: 4,
                            cityName: '徐州',
                            cityReside: 001

                        },
                        {
                            cityId: 5,
                            cityName: '无锡',
                            cityReside: 001

                        },
                        {
                            cityId: 6,
                            cityName: '南通',
                            cityReside: 001


                        },
                        {
                            cityId: 7,
                            cityName: '连云港',
                            cityReside: 001

                        },
                        {
                            cityId: 8,
                            cityName: '淮安',
                            cityReside: 001

                        },
                        {
                            cityId: 9,
                            cityName: '盐城',
                            cityReside: 001

                        },
                        {
                            cityId: 10,
                            cityName: '扬州',
                            cityReside: 001

                        },
                        {
                            cityId: 11,
                            cityName: '镇江',
                            cityReside: 001

                        },
                        {
                            cityId: 12,
                            cityName: '泰州',
                            cityReside: 001

                        },
                        {
                            cityId: 13,
                            cityName: '宿迁',
                            cityReside: 001

                        }
                    ],
                    // 区域
                    areaArr: [{
                            areaId: 10,
                            areaName: '吴江区',
                            areaReside: 1

                        },
                        {
                            areaId: 20,
                            areaName: '工业园区',
                            areaReside: 1

                        },
                        {
                            areaId: 30,
                            areaName: '张家港市',
                            areaReside: 1

                        },
                        {
                            areaId: 40,
                            areaName: '太仓市',
                            areaReside: 1
                        },
                        {
                            areaId: 50,
                            areaName: '张家港市',
                            areaReside: 1
                        },
                        {
                            areaId: 60,
                            areaName: '昆山市',
                            areaReside: 1
                        }
                    ],
                    // 商圈
                    placeArr: [{
                            placeId: 601,
                            placeName: '金鸡湖',
                            placeDistance: 9.8,
                            TradingAreaId: 100
                        },
                        {
                            placeId: 602,
                            placeName: '观前街',
                            placeDistance: 8.8,
                            TradingAreaId: 100
                        },
                        {
                            placeId: 103,
                            placeName: '苏州寒山寺',
                            placeDistance: 8.8,
                            TradingAreaId: 100

                        },
                        {
                            placeId: 104,
                            placeName: '虎丘',
                            placeDistance: 7.8,
                            TradingAreaId: 100

                        },
                        {
                            placeId: 105,
                            placeName: '平江路',
                            placeDistance: 6.8,
                            TradingAreaId: 100

                        },
                        {
                            placeId: 106,
                            placeName: '山塘街历史街区',
                            placeDistance: 6.0,
                            TradingAreaId: 100

                        }
                    ]
                }
            },

            // 方法
            methods: {
                //调整每页查询数量
                handleSizeChange(val) {
                    // console.log(`每页 ${val} 条`);
                    var that = this
                    that.pageSize = val
                },
                //当前页
                handleCurrentChange(val) {
                    // console.log(`当前页: ${val}`);
                    var that = this
                    that.currentPage = val - 1
                    that.elasticSearchGetHotelList(that.currentPage) // 调用分页查询
                },

                // 分页查询
                getHotelList() {
                    debugger
                    var that = this
                    console.log(that.currentPage)
                    console.log(that.pageSize)
                    axios({
                        method: 'get',
                        url: "http://localhost:8080/hotel/getByPage" + "?currentPage=" + that
                            .currentPage + "&pageSize=" + that.pageSize
                    }).then(function (resp) {
                        console.log(resp.data)
                        that.hotelTotal = resp.data.data.total
                        var array = resp.data.data.records
                        // 临时处理图片
                        for (let i = 0; i < array.length; i++) {
                            array[i].hotelShowImg = that.img
                        }
                        that.hotelArr = array
                        // console.log(that.hotelArr)
                    })
                },

                // 跳转到详情页面,传值
                checkDetail(i) {
                    if (window.localStorage) {
                        if (this.admin != null) {
                            let phone = this.admin.userPhone
                            console.log(phone)
                            localStorage.setItem(phone, JSON.stringify(this.admin))
                            console.log(this.esList)
                            localStorage.setItem("hotelId", JSON.stringify(this.hotelArr[i]))
                            console.log(this.hotelArr[i])
                            localStorage.hotelinformation = this.hotelArr[i];
                            console.log("需要发送给下个页面的参数")
                            console.log(JSON.stringify(this.admin))
                            console.log(JSON.stringify(this.hotelArr[i]))
                            location.href = 'details/details.html?phone=' + phone + '&hotelId=' + this.hotelArr[
                                i]
                        } else {
                            localStorage.setItem("hotelId", JSON.stringify(this.hotelArr[i]))
                            localStorage.hotelinformation = this.hotelArr[i];
                            location.href = 'details/details.html?hotelId=' + this.hotelArr[i]
                        }

                    }
                },

                // 是否关闭城市选项
                closeCity() {
                    if (this.isShowForm) {
                        this.isShowForm = false;
                        this.monitor = window.pageYOffset;
                        console.log(this.monitor)
                    } else {
                        this.isShowForm = true;
                    }
                },

                // 是否关闭悬浮搜选框城市选项
                closeCity2() {
                    if (this.isShowFormXF) this.isShowFormXF = false;
                    else this.isShowFormXF = true;
                },

                // 选择城市
                selectCity(e) {
                    this.city = e.currentTarget.innerHTML
                    // console.log(e.currentTarget.innerHTML )
                },

                // 搜索按钮
                searchBtn() {
                    //清空缓存
                    localStorage.clear();
                    console.log(this.admin)
                    if (this.admin != null) {
                        let phone = this.admin.userPhone
                        console.log(phone)
                        localStorage.setItem(phone, JSON.stringify(this.admin))
                        localStorage.setItem("searchTxt", JSON.stringify(this.txtStr))
                        console.log("需要发送给下一个页面的数据")
                        console.log(JSON.stringify(this.admin))
                        console.log(JSON.stringify(this.txtStr))
                        window.location.href = "screen.html?phone=" + phone
                    } else {
                        localStorage.setItem("searchTxt", JSON.stringify(this.txtStr))
                        window.location.href = "screen.html"
                    }

                },

                // 快排
                dealhotelData(left, right, array) {
                    // debugger
                    if (left < right) {
                        var i = left
                        var j = right
                        var target = array[left]
                        while (i < j) {
                            while (array[j].hotelMark <= target.hotelMark && i < j) {
                                j--;
                            }
                            while (array[i].hotelMark >= target.hotelMark && i < j) {
                                i++;
                            }
                            if (i < j) {
                                var temp = array[j];
                                array[j] = array[i];
                                array[i] = temp;
                            }
                        }
                        array[left] = array[i]
                        array[i] = target
                        dealhotelData(left, i - 1, array)
                        dealhotelData(j + 1, right, array)
                    }
                    return array
                },

                // 查询所有
                // getALL() {
                //     var that = this
                //     axios({
                //         method: 'get',
                //         url: "http://localhost:8080/hotel/getIHotelList"
                //     }).then(function (resp) {
                //         console.log(resp.data.data)
                //         that.hotelTotal = resp.data.data.length
                //     })
                // },

                // 价格降序
                priceDescBtn() {
                    var that = this
                    for (let i = 0; i < this.esList.length - 1; i++)
                        for (let j = 0; j < this.esList.length - 1 - i; j++) {
                            if (this.esList[j].roomLeastPrice > this.esList[j + 1].roomLeastPrice) {
                                let temp = this.esList[j]
                                that.esList[j] = this.esList[j + 1]
                                that.esList[j + 1] = temp
                            }
                        }
                    let temp = this.esList
                    console.log(temp)
                    this.esList = []
                    this.esList = temp
                },

                // 价格升序
                priceAscBtn() {
                    var that = this
                    for (let i = 0; i < this.esList.length - 1; i++)
                        for (let j = 0; j < this.esList.length - 1 - i; j++) {
                            if (this.esList[j].roomLeastPrice < this.esList[j + 1].roomLeastPrice) {
                                let temp = this.esList[j]
                                that.esList[j] = this.esList[j + 1]
                                that.esList[j + 1] = temp
                            }
                        }
                    let temp = this.esList
                    console.log(temp)
                    this.esList = []
                    this.esList = temp
                },
                // 评论降序
                remarkDescBtn() {

                },
                // 冒泡排序
                bubbleSort(array) {

                },
                //按照酒店姓名对ElasticSearch进行查询
                elasticSearchByName(pageNum) {
                    this.esList = []
                    this.hotelArr = []
                    var that = this
                    let txtStr = JSON.parse(localStorage.getItem("searchTxt"))
                    if (txtStr != "" && txtStr != null) {
                        that.txtStr = txtStr
                        console.log("数据添加成功:" + this.txtStr)
                        localStorage.removeItem("searchTxt")
                    }
                    if (this.txtStr == "" || this.txtStr == null) {
                        //没有搜索内容
                        axios({
                            method: "get",
                            url: "http://localhost:8080/hotelList/findByPage/" + pageNum
                        }).then(function (resp) {
                            for (let i = 0; i < resp.data.content.length; i++) {
                                that.esList.push(resp.data.content[i])
                                that.hotelArr.push(resp.data.content[i].hotelId)
                            }
                        })
                    } else {
                        //按照酒店名进行搜索
                        axios({
                            method: "get",
                            url: "http://localhost:8080/hotelList/findByHotelName/" + this.txtStr +
                                "/" + pageNum
                        }).then(function (resp) {
                            for (let i = 0; i < resp.data.content.length; i++) {
                                that.esList.push(resp.data.content[i])
                                that.hotelArr.push(resp.data.content[i].hotelId)
                            }
                        })
                    }
                },

                //elasticSearch酒店页面分页查询
                elasticSearchGetHotelList(currentPage) {
                    var that = this
                    console.log(currentPage)
                    that.esPage = 1
                    //是否按照名称查询（分别对应不同接口）
                    that.elasticSearchByName(currentPage)
                },

                //分页查询总数据量
                elasticSearchPageNum() {
                    var that = this
                    let txtStr = JSON.parse(localStorage.getItem("searchTxt"))
                    if (txtStr == "" || txtStr == null) {
                        //获取分页查询总数据
                        axios({
                            method: "get",
                            url: "http://localhost:8080/hotelList/esFindAllLength"
                        }).then(function (resp) {
                            that.hotelTotal = resp.data
                        })
                    } else {
                        //获取分页查询总数据
                        axios({
                            method: "get",
                            url: "http://localhost:8080/hotelList/findAllLengthByName/" + txtStr
                        }).then(function (resp) {
                            that.hotelTotal = resp.data
                        })
                    }
                },


                // 跳转到客服页面
                skipToCustomerServer() {
                    var that = this
                    if (that.admin != null) window.location.href =
                        "../../html/coupon/customer_service/chatting.html?userAdmin=" + that.admin.userAdmin
                    else window.location.href = "../../html/coupon/customer_service/chatting.html"

                },

                // 个人中心
                skipToCustomer() {
                    var that = this
                    if (that.admin != null) window.location.href =
                        "../../html/customer/center_index.html?userId=" + that.admin.userId
                    else window.location.href = "../../html/customer/center_index.html"
                },

                // 退出登录
                signOut() {
                    // 清空缓存
                    window.localStorage.clear()
                    // 清空用户信息
                    this.admin = {}
                    this.isLogin = false
                    // 跳转到登录页面
                    // window.location.href = "../admin/admin.html"
                },

                // 跳转到首页
                skipToIndex() {
                    var that = this
                    if (that.admin != null) window.location.href =
                        "../index/index.html?phone=" + that.admin.userPhone
                    else  window.location.href =
                        "../index/index.html"
                }

            },

            // 钩子函数
            created() {
               
            },

            mounted () {
                var that = this
                // 取出缓存中的用户数据
                var url = decodeURI(window.location.href);
                console.log(url)
                var phone = url.split("?phone=")[1]
                console.log(phone)
                console.log("本地缓存:" + JSON.parse(window.localStorage.getItem(phone)))
                //获取从主页传过来的用户信息(目前为字符串)
                let adminStr = localStorage.getItem(phone)
                console.log(adminStr)
                //json格式转换之后 赋值给admin对象
                that.admin = JSON.parse(adminStr)
                console.log(this.admin)
                // this.hotelArr = this.dealhotelData(0, this.hotelArr.length - 1, this.hotelArr)
                // that.getHotelList()
                //分页查询总数据量
                that.elasticSearchPageNum()
                //是否按照酒店名进行分页查询
                that.elasticSearchByName(0)
                that.priceDescBtn()
                if (that.admin != null) {
                    this.isLogin = true
                } else this.isLogin = false
            }
        })
    </script>
</body>

</html>